<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>avalon: E:/avalon/src/libavalon/connecter.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">avalon
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.12.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search',false);
  $(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){ initResizable(false); });
/* @license-end */
</script>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li><li class="navelem"><a class="el" href="dir_f51b14f5b402f75e5fe3fdf41b0bea7b.html">libavalon</a></li>  </ul>
</div>
</div><!-- top -->
<div id="doc-content">
<div class="header">
  <div class="headertitle"><div class="title">connecter.h</div></div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno">    1</span><span class="preprocessor">#ifndef CONNECTER_H_</span></div>
<div class="line"><a id="l00002" name="l00002"></a><span class="lineno">    2</span><span class="preprocessor">#define CONNECTER_H_</span></div>
<div class="line"><a id="l00003" name="l00003"></a><span class="lineno">    3</span> </div>
<div class="line"><a id="l00004" name="l00004"></a><span class="lineno">    4</span><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><a id="l00005" name="l00005"></a><span class="lineno">    5</span><span class="preprocessor">#include &lt;vector&gt;</span></div>
<div class="line"><a id="l00006" name="l00006"></a><span class="lineno">    6</span><span class="preprocessor">#include &lt;mutex&gt;</span></div>
<div class="line"><a id="l00007" name="l00007"></a><span class="lineno">    7</span><span class="preprocessor">#include &lt;atomic&gt;</span></div>
<div class="line"><a id="l00008" name="l00008"></a><span class="lineno">    8</span> </div>
<div class="line"><a id="l00009" name="l00009"></a><span class="lineno">    9</span><span class="keyword">class </span>event_base;</div>
<div class="line"><a id="l00010" name="l00010"></a><span class="lineno">   10</span><span class="keyword">class </span><a class="code hl_class" href="class_connect_handler.html">ConnectHandler</a>;</div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno">   11</span><span class="keyword">namespace </span>AMQP</div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno">   12</span>{</div>
<div class="line"><a id="l00013" name="l00013"></a><span class="lineno">   13</span>    <span class="keyword">class </span>TcpConnection;</div>
<div class="line"><a id="l00014" name="l00014"></a><span class="lineno">   14</span>    <span class="keyword">class </span>TcpChannel;</div>
<div class="line"><a id="l00015" name="l00015"></a><span class="lineno">   15</span>}</div>
<div class="line"><a id="l00016" name="l00016"></a><span class="lineno">   16</span><span class="keyword">class </span><a class="code hl_class" href="class_provider.html">Provider</a>;</div>
<div class="line"><a id="l00017" name="l00017"></a><span class="lineno">   17</span><span class="keyword">class </span><a class="code hl_class" href="class_deliver.html">Deliver</a>;</div>
<div class="line"><a id="l00018" name="l00018"></a><span class="lineno">   18</span> </div>
<div class="foldopen" id="foldopen00023" data-start="{" data-end="};">
<div class="line"><a id="l00023" name="l00023"></a><span class="lineno"><a class="line" href="class_connecter.html">   23</a></span><span class="keyword">class </span><a class="code hl_class" href="class_connecter.html">Connecter</a></div>
<div class="line"><a id="l00024" name="l00024"></a><span class="lineno">   24</span>{</div>
<div class="line"><a id="l00025" name="l00025"></a><span class="lineno">   25</span><span class="keyword">public</span>:</div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno">   31</span>    <span class="keyword">explicit</span> <a class="code hl_function" href="class_connecter.html#a133e45342124deeab7b7be1dbe4b15f6">Connecter</a>(<span class="keywordtype">int</span> <span class="keywordtype">id</span>, <span class="keyword">const</span> std::string &amp;amqp_address);</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno">   32</span> </div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno">   36</span>    <a class="code hl_function" href="class_connecter.html#aead3ee0475b88557a6a98e58a0c2be00">~Connecter</a>();</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno">   37</span> </div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno">   41</span>    <span class="keywordtype">void</span> <a class="code hl_function" href="class_connecter.html#a51019cfe7a2587a2ca6941235876a0d2">start</a>();</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno">   42</span> </div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno">   46</span>    <span class="keywordtype">void</span> <a class="code hl_function" href="class_connecter.html#ae5e5d065d1451410916fca8475d57058">run</a>();</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno">   47</span> </div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno">   52</span>    <span class="keywordtype">bool</span> <a class="code hl_function" href="class_connecter.html#aea60e43d17860a3a85011795ca94aac6">setup</a>();</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno">   53</span> </div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno">   59</span>    <span class="keywordtype">void</span> <a class="code hl_function" href="class_connecter.html#a2bb72edb16926086fd48eb4cb0737981">notify</a>(<span class="keywordtype">int</span> fd, <span class="keywordtype">short</span> which);</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno">   60</span> </div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno">   64</span>    <span class="keywordtype">void</span> <a class="code hl_function" href="class_connecter.html#a0924d067d995abaf1784d0befbbdc6d8">reconnect</a>();</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno">   65</span> </div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno">   70</span>    <span class="keywordtype">void</span> <a class="code hl_function" href="class_connecter.html#af39eff4ec5d147fb74ca49299f37f082">addProvider</a>(<a class="code hl_class" href="class_provider.html">Provider</a> *provider);</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno">   71</span> </div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno">   76</span>    <span class="keywordtype">void</span> <a class="code hl_function" href="class_connecter.html#a54fa88894648d542cb425fc1a7905130">addDeliver</a>(<a class="code hl_class" href="class_deliver.html">Deliver</a> *deliver);</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno">   77</span> </div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno">   78</span><span class="keyword">private</span>:</div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno">   82</span>    <span class="keywordtype">void</span> connect();</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno">   83</span> </div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno">   88</span>    <span class="keywordtype">void</span> send(<a class="code hl_class" href="class_deliver.html">Deliver</a>* deliver);</div>
<div class="line"><a id="l00089" name="l00089"></a><span class="lineno">   89</span> </div>
<div class="line"><a id="l00094" name="l00094"></a><span class="lineno">   94</span>    <span class="keywordtype">void</span> sendAndReceive(<a class="code hl_class" href="class_deliver.html">Deliver</a>* deliver);</div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno">   95</span> </div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno">   96</span><span class="keyword">private</span>:</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno">   98</span>    <span class="keywordtype">int</span> id_;</div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno">  100</span>    std::string amqp_address_;</div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno">  102</span>    event_base *base_;</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno">  104</span>    <span class="keywordtype">int</span> notify_send_fd_;</div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno">  106</span>    std::mutex task_mutex_;</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno">  107</span> </div>
<div class="line"><a id="l00109" name="l00109"></a><span class="lineno">  109</span>    <a class="code hl_class" href="class_connect_handler.html">ConnectHandler</a> *handler_;</div>
<div class="line"><a id="l00111" name="l00111"></a><span class="lineno">  111</span>    AMQP::TcpConnection *connection_;</div>
<div class="line"><a id="l00113" name="l00113"></a><span class="lineno">  113</span>    AMQP::TcpChannel *channel_;</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno">  115</span>    std::vector&lt;Provider *&gt; providers_;</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno">  117</span>    <span class="keywordtype">int</span> reconnect_interval_;</div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno">  119</span>    std::vector&lt;Deliver *&gt; delivers_;</div>
<div class="line"><a id="l00121" name="l00121"></a><span class="lineno">  121</span>    std::atomic&lt;int&gt; seq_;</div>
<div class="line"><a id="l00122" name="l00122"></a><span class="lineno">  122</span>};</div>
</div>
<div class="line"><a id="l00123" name="l00123"></a><span class="lineno">  123</span> </div>
<div class="line"><a id="l00124" name="l00124"></a><span class="lineno">  124</span><span class="preprocessor">#endif </span><span class="comment">// CONNECTER_H_</span></div>
<div class="ttc" id="aclass_connect_handler_html"><div class="ttname"><a href="class_connect_handler.html">ConnectHandler</a></div><div class="ttdoc">ConnectHandler类继承自AMQP::LibEventHandler，用于处理与AMQP相关的事件， 如连接建立、心跳接收、连接丢失和错误等。</div><div class="ttdef"><b>Definition</b> connect_handler.h:14</div></div>
<div class="ttc" id="aclass_connecter_html"><div class="ttname"><a href="class_connecter.html">Connecter</a></div><div class="ttdoc">定义一个连接器类，用于建立和维护与消息队列服务器的连接</div><div class="ttdef"><b>Definition</b> connecter.h:24</div></div>
<div class="ttc" id="aclass_connecter_html_a0924d067d995abaf1784d0befbbdc6d8"><div class="ttname"><a href="class_connecter.html#a0924d067d995abaf1784d0befbbdc6d8">Connecter::reconnect</a></div><div class="ttdeci">void reconnect()</div><div class="ttdoc">重新连接消息队列服务器</div><div class="ttdef"><b>Definition</b> connecter.cpp:120</div></div>
<div class="ttc" id="aclass_connecter_html_a133e45342124deeab7b7be1dbe4b15f6"><div class="ttname"><a href="class_connecter.html#a133e45342124deeab7b7be1dbe4b15f6">Connecter::Connecter</a></div><div class="ttdeci">Connecter(int id, const std::string &amp;amqp_address)</div><div class="ttdoc">构造函数，初始化连接器对象</div><div class="ttdef"><b>Definition</b> connecter.cpp:19</div></div>
<div class="ttc" id="aclass_connecter_html_a2bb72edb16926086fd48eb4cb0737981"><div class="ttname"><a href="class_connecter.html#a2bb72edb16926086fd48eb4cb0737981">Connecter::notify</a></div><div class="ttdeci">void notify(int fd, short which)</div><div class="ttdoc">通知连接器有事件发生</div><div class="ttdef"><b>Definition</b> connecter.cpp:83</div></div>
<div class="ttc" id="aclass_connecter_html_a51019cfe7a2587a2ca6941235876a0d2"><div class="ttname"><a href="class_connecter.html#a51019cfe7a2587a2ca6941235876a0d2">Connecter::start</a></div><div class="ttdeci">void start()</div><div class="ttdoc">启动连接器，开始连接消息队列服务器</div><div class="ttdef"><b>Definition</b> connecter.cpp:42</div></div>
<div class="ttc" id="aclass_connecter_html_a54fa88894648d542cb425fc1a7905130"><div class="ttname"><a href="class_connecter.html#a54fa88894648d542cb425fc1a7905130">Connecter::addDeliver</a></div><div class="ttdeci">void addDeliver(Deliver *deliver)</div><div class="ttdoc">添加一个消息投递者</div><div class="ttdef"><b>Definition</b> connecter.cpp:230</div></div>
<div class="ttc" id="aclass_connecter_html_ae5e5d065d1451410916fca8475d57058"><div class="ttname"><a href="class_connecter.html#ae5e5d065d1451410916fca8475d57058">Connecter::run</a></div><div class="ttdeci">void run()</div><div class="ttdoc">运行事件循环，处理各种事件</div><div class="ttdef"><b>Definition</b> connecter.cpp:49</div></div>
<div class="ttc" id="aclass_connecter_html_aea60e43d17860a3a85011795ca94aac6"><div class="ttname"><a href="class_connecter.html#aea60e43d17860a3a85011795ca94aac6">Connecter::setup</a></div><div class="ttdeci">bool setup()</div><div class="ttdoc">设置连接器，包括建立到消息队列服务器的连接等</div><div class="ttdef"><b>Definition</b> connecter.cpp:56</div></div>
<div class="ttc" id="aclass_connecter_html_aead3ee0475b88557a6a98e58a0c2be00"><div class="ttname"><a href="class_connecter.html#aead3ee0475b88557a6a98e58a0c2be00">Connecter::~Connecter</a></div><div class="ttdeci">~Connecter()</div><div class="ttdoc">析构函数，释放连接器对象</div><div class="ttdef"><b>Definition</b> connecter.cpp:24</div></div>
<div class="ttc" id="aclass_connecter_html_af39eff4ec5d147fb74ca49299f37f082"><div class="ttname"><a href="class_connecter.html#af39eff4ec5d147fb74ca49299f37f082">Connecter::addProvider</a></div><div class="ttdeci">void addProvider(Provider *provider)</div><div class="ttdoc">添加一个消息提供者</div><div class="ttdef"><b>Definition</b> connecter.cpp:155</div></div>
<div class="ttc" id="aclass_deliver_html"><div class="ttname"><a href="class_deliver.html">Deliver</a></div><div class="ttdoc">类，用于处理消息的投递。</div><div class="ttdef"><b>Definition</b> deliver.h:40</div></div>
<div class="ttc" id="aclass_provider_html"><div class="ttname"><a href="class_provider.html">Provider</a></div><div class="ttdoc">服务提供者基类</div><div class="ttdef"><b>Definition</b> provider.h:24</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.12.0
</small></address>
</div><!-- doc-content -->
</body>
</html>
